/**
 * Copyright (c) 2013 Mark Tielemans
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * DISCLAIMER
 * This software is provided "as is" and any expressed or implied warranties, including, but not limited to, the implied warranties of 
 * merchantability and fitness for a particular purpose are disclaimed. In no event shall the regents or contributors be liable for any 
 * direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute 
 * goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in 
 * contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if 
 * advised of the possibility of such damage.
 */
package nl.marktielemans.easydb.generator;

import java.util.List;

import nl.marktielemans.easydb.DatabaseVendor;
import nl.marktielemans.easydb.model.DatabaseTable;
import nl.marktielemans.easydb.model.EasyDBEntity;
import nl.marktielemans.easydb.model.TableColumn;

/**
 * Contains methods for query generation, to be implemented for each supported {@link DatabaseVendor}.
 * 
 * @author Mark Tielemans
 * @since 1.0
 * @version 1.0
 */
public interface QueryGenerator {
	/**
	 * Generate a <code>CREATE TABLE IF NOT EXISTS</code> query for a given {@link DatabaseTable}.
	 * @param table
	 * @return generated query
	 */
	public String generateCreateTableQuery(DatabaseTable table);
	
	/**
	 * Generate a <code>DROP TABLE</code> query for a given {@link DatabaseTable}.
	 * @param table
	 * @return generated query
	 */
	public String generateDropQuery(DatabaseTable table);
	
	/**
	 * Generate a <code>INSERT INTO</code> query for a given {@link DatabaseTable}, using the given 
	 * {@link EasyDBEntity} for property values.
	 * @param table
	 * @param entity properties to be used
	 * @return generated query
	 * @see EasyDBEntity#getProperties()
	 */
	public String generateInsertQuery(DatabaseTable table, EasyDBEntity entity);
	
	/**
	 * Generate an <code>UPDATE</code> query for the given {@link DatabaseTable}, using the given 
	 * {@link EasyDBEntity} for new values and the given list of property values as conditions.
	 * 
	 * @param table
	 * @param entity
	 * @param conditions
	 * @return generated query
	 * @see EasyDBEntity#getProperties()
	 */
	public String generateUpdateQuery(DatabaseTable table, EasyDBEntity entity, List<TableColumn<?>> conditions);
	
	/**
	 * Generate a simple <code>SELECT</code> query for the given {@link DatabaseTable}, using the 
	 * given list of property values as conditions. Does not support joins.
	 * 
	 * @param table
	 * @param conditions
	 * @return generated query
	 */
	public String generateSimpleSelectQuery(DatabaseTable table, List<TableColumn<?>> conditions);
	
	/**
	 * Generate a <code>DELETE</code> query for the given {@link DatabaseTable}, using the given list 
	 * of property values as conditions.
	 * 
	 * @param databaseTable
	 * @param conditions
	 * @return generated query
	 */
	public String generateDeleteQuery(DatabaseTable databaseTable, List<TableColumn<?>> conditions);
}
